package com.dragon.common.utils;

public class ECYUtils {
	
	public static Integer TIECODE(String kind) {
		if(kind.indexOf("生死平")>=0) {
			return 2;
		}else if(kind.indexOf("生死")>=0) {
			return 1;
		}else if(kind.indexOf("赢半")>=0) {
			return 3;
		}else if(kind.indexOf("平手")>=0) {
			return 4;
		}else if(kind.indexOf("输半")>=0) {
			return 5;
		}else {
			return 0;
		}
	} 
	
	public static Double MIXODDS(Double odds, Double rebate) {
		return odds*(1+rebate)-2*rebate;
	}
	
	public static Double MIXTIEODDS(String kind, Double odds, Double rebate) {
		Integer code = TIECODE(kind);
		switch (code) {
			case 1:
				return 0d;
			case 2:
				return odds;
			case 3:
				return (odds + rebate - 1) / 2;
			case 4:
				return odds + rebate - 1;
			case 5:
				return odds + (rebate - 1) / 2;
			default:
				return null;
		}
	}
	
	public static Double CASINOODDS(String kind, Double odds, Double tie) {
		Integer code = TIECODE(kind);
		switch (code) {
			case 1:
				return odds;
			case 2:
				return 1/(1/odds+1/tie);
			case 3:
				return odds*tie/(odds+tie-0.5-odds/2);
			case 4:
				return odds * tie / (odds + tie - 1);
			case 5:
				return odds * tie / (odds + tie - 0.5);
			default:
				return null;
		}
	}
	
	public static Double TIEREBATE(String kind, Double odds) {
		Integer code = TIECODE(kind);
		switch (code) {
			case 1:
				return 0d;
			case 2:
				return 1d;
			case 3:
				return (odds - 1) / 2;
			case 4:
				return 0d;
			case 5:
				return 0.5;
			default:
				return null;
		}
	}
	
	public static Double TIEODDS(String kind, Double odds) {
		Integer code = TIECODE(kind);
		switch (code) {
			case 1:
				return 0d;
			case 2:
				return 0d;
			case 3:
				return (odds + 1) / 2;
			case 4:
				return 1d;
			case 5:
				return 0.5;
			default:
				return null;
		}
	}

}
